package com.example.satokendemospringboot;

import cn.dev33.satoken.SaTokenManager;
import cn.dev33.satoken.spring.SaTokenSetup;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

@Slf4j
@SaTokenSetup  //sa-token启用注解
@SpringBootApplication
public class SaTokenDemoSpringbootApplication {





    public static void main(String[] args) throws UnknownHostException {

        ConfigurableApplicationContext application = SpringApplication.run(SaTokenDemoSpringbootApplication.class, args);
        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
//        String ymlProfile = env.getProperty("spring.profiles.active");
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");
        log.info("\n----------------------------------------------------------\n\t" +
                " Application is running! Access URLs:\n\t" +
//                "ymlProfile: \t\t" + ymlProfile + "\n\t" +
                "Local: \t\thttp://localhost:" + port + path+ "/\n\t" +
                "External: \thttp://" + ip + ":" + port + path +"/\n\t" +
                "----------------------------------------------------------");

        System.out.println("启动成功：sa-token配置如下：" + SaTokenManager.getConfig());
    }

}
